﻿#include "Application.h"
#include "CommandLine.h"

#include <vtkm/cont/RuntimeDeviceTracker.h>

Application::Application(int argc, char** argv)
{
  _command_line = std::make_unique<CommandLine>(argc, argv);
}

Application::~Application() {}

void Application::SetupDevice()
{
  auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
  if (!tracker.CanRunOn(*_device))
  {
    Error(
      "不能在 Device Tag: ", _device->GetName(), "上运行，", "选项：serial|cuda|tbb|openmp|hip");
  }

  Info("Device Tag: ", _device->GetName());
  tracker.ForceDevice(*_device);
}

void Application::Run()
{

  //vtkm::cont::ScopedRuntimeDeviceTracker track(tbb);

  PrintLogo(); // 打印logo

  ParseCLI(); //解析命令行

  CreateActions(); // 解析配置文件，创建Actions
}
void Application::AddOutput(std::shared_ptr<Output> output)
{
  _owh.push_back(output);
}
void Application::AddUserObject(std::shared_ptr<UserObject> uo)
{
  _uos.push_back(uo);
};

void Application::PrintLogo()
{
  auto logo = R"(
                                                                                       
   @@@@@@@@@     .@@.     =@@@@@@]        @@`      @\       @ 
         =@`     @/=@     =@     \@`     //=@      @\@.     @ 
        /@.     =@  @\    =@     =@^    =@. \\     @ ,@`    @ 
      ,@/      =@`  ,@^   =@   ,/@/    ,@`   @^    @  .@\   @ 
     /@`      ,@\]]]]/@`  =@[[\@`      @\]]]]/@`   @    \@. @ 
   ,@/        @/      \@  =@   ,@^    /@      =@.  @     =@`@ 
  =@\]]]]]]] /@        @\ =@    .@\  =@.       @\  @      ,@@ 
  ---------------------------------------------------------------

)";
  std::cout << logo;
}

void Application::ParseCLI() {}

void Application::CreateActions() {}
